package com.hejia.alauda.service;

import java.util.Date;
import java.util.List;

import com.hejia.alauda.entity.HejiaRedPacket;
import com.hejia.alauda.entity.HejiaRedPacketReceive;
import com.hejia.alauda.entity.User;
import com.hejia.alauda.utils.Pager;

/**
 * 合家红包服务
 * @author hyr
 *
 */
public interface HejiaRedPacketService {

	/**
	 * 查询合家红包
	 * @param pager
	 * @param startTime 查询开始时间
	 * @param endTime 查询结束时间
	 * @return
	 */
	Pager<HejiaRedPacket> findHejiaRedPackets(Pager<HejiaRedPacket> pager, Date startTime, Date endTime);

	/**
	 * 添加合家红包
	 * @param hejiaRedPacket
	 * @return
	 */
	HejiaRedPacket addHejiaRedPacket(HejiaRedPacket hejiaRedPacket);

	/**
	 * 删除合家红包
	 * @param id
	 */
	void deleteHejiaRedPacket(Long id);

	/**
	 * 查询合家红包
	 * @param externalId 外部ID
	 * @return
	 */
	HejiaRedPacket findhejiaRedPacketByExternalId(String externalId);

	/**
	 * 抢红包
	 * @param externalId 外部ID
	 * @return
	 */
	HejiaRedPacketReceive grapHejiaRedPacketByExternalId(User user, String externalId);

	/**
	 * 统计用户领取红包数量
	 * @param user	用户
	 * @param externalId 外部ID
	 * @return
	 */
	int countReceivedRedPacket(User user, String externalId);
	
	/**
	 * 根据红包ID查询已抢红包的信息（userId != null）
	 * 
	 * @param externalId
	 * @return
	 */
	List<HejiaRedPacketReceive> findHejiaRedPacketGrapInfoByRedPacketId(Long redPacketId);
	
	

}
